package main;

import java.io.File;
import java.io.IOException;

import utils.RaidControllerLab3;

import com.google.common.primitives.Ints;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		if(args.length != 3) {
			System.out.println("we need 3 args");
			return;
		}
		
		String root = args[0];
		Integer block = Ints.tryParse(args[1]);
		String filePath = args[2];
		File file = new File(filePath);
		if(!file.exists())
			try {
				file.createNewFile();
			} catch (IOException e) {
				e.printStackTrace();
			}
		RaidControllerLab3 controller = new RaidControllerLab3(root);
		if(block < 1) {
			System.out.println("block must be from 1 to " + controller.getInfo().getBlockCount());
			return;
		}
		controller.readFile(block - 1, file);
	}

}
